﻿
@{
    ViewBag.Title = "CommReport";
    ViewBag.First = "报表中心";
    ViewBag.Second = ViewData["tmp"];
    Layout = "~/Views/Shared/_BaseLayout.cshtml";
    var list = ViewData["olist"] as IList<Sc.Domain.CommOrgz>;
}
<script src="~/Content/laydate-v1.1/laydate/laydate.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        initDate("start", "end", "YYYY/MM/DD hh:mm:ss");
        $(".select2").uedSelect({
            width: 167
        });
        loadData();
    });
    //数据加载
    function loadData() {
        var url = '@Url.Action("GetCommReportData")';
        var load = loadTip("数据加载中，请稍候", 16, 0);
        $.get(url, { orgz: $("#selOrgz").val(), start: $("#start").val(), end: $("#end").val(),tag:@ViewData["tag"] }, function (data) {
            $("#listData").find("tr").remove();
            var table = document.getElementById("listData");
            var total = 0;
            $.each(data, function (index, n) {
                var row = table.insertRow(table.rows.length);
                row.insertCell(0).innerHTML = (index + 1);
                row.insertCell(1).innerHTML = n.CarNo;
                row.insertCell(2).innerHTML = n.CarTypeName;
                row.insertCell(3).innerHTML = n.UseCount;
                row.insertCell(4).innerHTML = n.Money;
                total += n.Money;
            });
            var co = table.insertRow(table.rows.length);
            var f = co.insertCell(0);
            f.colSpan = 2; f.innerHTML = "合计";
            co.insertCell(1); co.insertCell(2); co.insertCell(3).innerHTML = "￥"+fmoney(total,2);
            $('.tablelist tbody tr:odd').addClass('odd');
            layer.close(load);
        });
    }
    //打印
    function p() {
        $(".scbtn").hide();
        window.print();
        $(".scbtn").show();
    }
</script>
<div id="content" class="rightinfo">
    <div id="tab2" class="tabson">
        <ul class="seachform">
            <li>
                <label>单位</label>
                <div class="vocation">
                    <select name="select" class="select2" id="selOrgz">
                        @foreach (var item in list)
                        {
                            <option value="@item.Id">@item.OrgzName</option>
                        }
                    </select>
                </div>
            </li>
            <li>
                <label>开始时间</label>
                <input type="text" id="start" value="@DateTime.Now.AddDays(-DateTime.Now.Day+1).ToString("yyyy-MM-dd 00:00:00")" readonly="readonly" class="scinput" />
            </li>
            <li>
                <label>结束时间</label>
                <input type="text" value="@DateTime.Now.AddDays(-DateTime.Now.Day + 1).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 23:59:59")" id="end" readonly="readonly" class="scinput" />
            </li>
            <li>
                <label>&nbsp;</label>
                <input name="Input" type="button" class="scbtn" onclick="loadData();" value="查询" />
                <label>&nbsp;</label>
                <input name="Input" type="button" class="scbtn" onclick="p();" value="打印" />
            </li>
        </ul>
    </div>
    <table class="tablelist">
        <thead>
            <tr>
                <th width="40px">编号</th>
                <th>车牌</th>
                <th>车型</th>
                <th>次数</th>
                <th>金额</th>
            </tr>
        </thead>
        <tbody id="listData"></tbody>
    </table>
</div>

